find_package(Git)
if(GIT_EXECUTABLE AND IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
    execute_process(
        COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
        OUTPUT_VARIABLE GIT_REVISION
        RESULT_VARIABLE GIT_REVISION_ERROR_CODE
        OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    execute_process(
        COMMAND ${GIT_EXECUTABLE} rev-parse --short=12 HEAD
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
        OUTPUT_VARIABLE GIT_COMMIT_ID
        RESULT_VARIABLE GIT_COMMIT_ID_ERROR_CODE
        OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    if(NOT GIT_REVISION_ERROR_CODE AND NOT GIT_COMMIT_ID_ERROR_CODE)
        set(LPAC_VERSION ${CMAKE_PROJECT_VERSION}.r${GIT_REVISION}.${GIT_COMMIT_ID})
    endif()
endif()
